package com.chixigua.chaos.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chixigua.chaos.entity.User;
import com.chixigua.chaos.mapper.UserMapper;
import com.chixigua.chaos.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chixigua.chaos.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author shane
 * @since 2020-04-08
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public JSONObject getUserList(String search) {
        User user=new User();
        QueryWrapper<User> userWrapper = new QueryWrapper<>();
        userWrapper.eq("2",2);
        userWrapper.and(wrapper -> wrapper.like("user_name", search).or().like("user_phone", search));
        List<User> users = userMapper.selectList(userWrapper);
        Page page=new Page(1,2);
        userMapper.selectPage(page,userWrapper);
       /* QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("1",1).;
        wrapper.like("user_name",search).or(true).eq();
        wrapper.or();
        wrapper.like("user_phone",search);
        List list = userMapper.selectList(wrapper);*/
        return JsonResult.successJson(users);
    }
}
